package com.runner.entity;

import com.badlogic.gdx.math.Vector2;

public abstract class CollisionEntity extends Entity {

	protected PhysicsComponent physics;

	public CollisionEntity(Vector2 position, TYPE t, String path, boolean isStatic, boolean sensor) {
		this(position, t, path, isStatic, sensor, true, 1);
	}

	public CollisionEntity(Vector2 position, TYPE t, String path, boolean isStatic, boolean sensor, boolean gravitational, float scale) {
		this(1, 1, position, t, path, isStatic, sensor, gravitational, scale);
	}

	public CollisionEntity(float cols, float rows, Vector2 position, TYPE t, String path, boolean isStatic, boolean sensor, boolean gravitational, float scale) {
		super(position, path, scale);
		physics = new PhysicsComponent(cols, rows, position, t, path, isStatic, sensor, gravitational, scale, graphics.getSprite(),this);

	}

	@Override
	public void setPosition(Vector2 position) {
		physics.setPosition(position, graphics.getSprite());
	}

	@Override
	public float renderXPosition(float width) {
		return physics.getBody().getPosition().x - width * 0.5f;
	}

	@Override
	public float renderYPosition(float height) {
		return physics.getBody().getPosition().y - height * 0.5f;
	}

	public void update(float delta) {
		physics.update(delta);
	}

	public void delete() {
		super.delete();
		physics.delete();

	}

	public abstract void collide(CollisionEntity otherBody);

	public PhysicsComponent getPhysics() {
		return physics;
	}

	public void setPhysics(PhysicsComponent physics) {
		this.physics = physics;
	}

	
}
